 define(["dojo/request/xhr","dojo/json"], function(xhr, JSON){
//define(["dojo/request/iframe","dojo/json"], function(iframe, JSON){
//define(["dojo/request","dojo/json"], function(request, JSON){

   
	 function prueba(){
		 
		 var urlInsertPrueba = "https://www.googleapis.com/fusiontables/v1/query?key=AIzaSyBuPTzjjHCiAnGObM9j4QlEUFEQVv2XFf0&sql=INSERT INTO 1EX8fAFpYb-oVM33jC72bHfSKUV-YOjMYc27MDA4 (ID, Nombre, Apellido, Date, Location) VALUES (3, 'Francisco', 'Garcia', '11/03/2013','40.420, -3.688')";
	//	 urlInsertPrueba = "https://www.googleapis.com/fusiontables/v1/query?key=AIzaSyBuPTzjjHCiAnGObM9j4QlEUFEQVv2XFf0&sql=SELECT Nombre FROM 1EX8fAFpYb-oVM33jC72bHfSKUV-YOjMYc27MDA4";
		 urlInsertPrueba = "https://www.googleapis.com/fusiontables/v1/query";
		 		
		 
	//	 urlInsertPrueba = "http://localhost:8080/Test_Maps/json/test.json";
		 console.log("Prueba url prueba con request: "+urlInsertPrueba);
		 
	//	 request(urlInsertPrueba,{
		 xhr(urlInsertPrueba,{
	//	 iframe(urlInsertPrueba,{
			 headers: {
		            'Content-type': 'application/x-www-form-urlencoded'
		        },
		      handleAs: "json"
		      ,method: "POST"
		      ,query:{
		    	  key: "AIzaSyBuPTzjjHCiAnGObM9j4QlEUFEQVv2XFf0",
		    	  sql: "SELECT Nombre FROM 1EX8fAFpYb-oVM33jC72bHfSKUV-YOjMYc27MDA4"
		      }
		    	 

			
		 }).then(
				 function(data){
	                	console.log("data: "+JSON.stringify(data));
	                    // Display the text file content
	             },
	             function(response){
	            	 console.log("response: "+JSON.stringify(response));
	                    // Display the text file content
	             },
	             function(error){
	                    // Display the error returned
	                	//console.log("error: "+JSON.stringify(error));
	                	console.log("error: "+JSON.stringify(error));
	                	
	             }
	 			);        
 	    };
 	    
 		 function testMyRestService(){
 			 
 			 var urlInsertPrueba = "http://localhost:8080/Test_Rest_Service/services/test/testRest";
 		//	 		
 			 
 		//	 urlInsertPrueba = "http://localhost:8080/Test_Maps/json/test.json";
 			 console.log("Prueba url prueba con request: "+urlInsertPrueba);
 			 
 		//	 request(urlInsertPrueba,{
 			 xhr(urlInsertPrueba,{
 		//	 iframe(urlInsertPrueba,{
 				/* headers: {
 			            'Content-type': 'application/x-www-form-urlencoded'
 			        },*/
 			      handleAs: "json"
 			      ,method: "GET"
 			      ,query:{
 			    	 strjson: "{name:Roberto,surname:Tejedor}"
 			      }
 			    	 

 				
 			 }).then(
 					 function(data){
 		                	console.log("data: "+JSON.stringify(data));
 		                	
 		                    // Display the text file content
 		             },
 		            function(text){
		                	console.log("text: "+JSON.stringify(text));
		                    // Display the text file content
		             }
 					 /*,
 		             function(response){
 		            	 console.log("response: "+JSON.stringify(response));
 		                    // Display the text file content
 		             },
 		             function(error){
 		                    // Display the error returned
 		                	//console.log("error: "+JSON.stringify(error));
 		                	console.log("error: "+JSON.stringify(error));
 		                	
 		             } */
 		 			);        
 	 	    };
	 
	 return{
		 prueba : prueba,
		 testMyRestService: testMyRestService
	 };
    
  
});




